package com.ruoyi.common.enums;

/**
 * 检测频率枚举
 * @author zhangwenqiang
 */
public enum FrequencyEums {

    ONCE_PER_BATCH(0, "1次/批"),
    ONCE_PER_MONTH(1, "1次/月"),
    ONCE_PER_QUARTER(2, "1次/季"),
    ONCE_PER_YEAR(3, "1次/年");

    private final int code;
    private final String description;

    // 构造函数
    FrequencyEums(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取对应的 code
    public int getCode() {
        return code;
    }

    // 获取对应的描述
    public String getDescription() {
        return description;
    }

    // 根据描述获取对应的 code
    public static int getCodeByDescription(String description) {
        for (FrequencyEums frequency : values()) {
            if (frequency.getDescription().equals(description)) {
                return frequency.getCode();
            }
        }
        throw new IllegalArgumentException("Unexpected description: " + description);
    }
}
